/**
 * @Author: lll
 * @Email:li.lele@vpclub.cn
 * @Date: create in 2020/7/14
 */
package cn.vpclub.admin.mapper;

import cn.vpclub.admin.entity.CommentEntity;
import cn.vpclub.admin.param.CommentResponseParam;
import cn.vpclub.admin.param.CommentResponseParamInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface CommentMapper extends BaseMapper<CommentEntity> {
    /**
     * 根据文章id查询评论
     *
     * @param articleId
     * @return
     */
    @Select("SELECT comment.id AS id, comment.comment_content AS content ,user.username AS username ,user.picture AS picture ,comment.createdTime AS createdTime " +
            "FROM comment, user WHERE comment.article_id = #{articleId} AND comment.user_id = user.id order by comment.createdTime DESC")
    List<CommentResponseParam> selectComment(String articleId);

    /**
     * 二级子查询
     *
     * @param articleId
     * @return
     */
    List<CommentResponseParamInfo> selectCommentInfo(String articleId);
}
